#include "bodypart_rigid_box.h"

BodypartRigidBox::BodypartRigidBox(const btVector3& dimensions, boost::shared_ptr<btDynamicsWorld> ownerWorld, void* owner, float weight, btVector3& localInertia, const btTransform& transform, const BeColor& clr, float lin_damping, float ang_damping)
  : BodypartRigid( BOX, clr, ownerWorld )
{
	shape = new btBoxShape( dimensions );

	// FIXME weight above -> density from material & calculate weight
	generalSetup( localInertia, weight, transform, owner, lin_damping, ang_damping );

	scale_halfExtent = static_cast<btBoxShape*>(shape)->getHalfExtentsWithMargin();
}

void BodypartRigidBox::draw()
{
	glColor4f( color.r, color.g, color.b, color.a );
// 	myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(position);
	glPushMatrix(); 
// 	glMultMatrixf(drawposition);
// 	glMultMatrixd(drawposition); // FIXME WATCHIT OK WENT TO DOUBLE HERE 
	Displaylists::Instance()->glMultiMatrix(drawposition);

		glScaled( scale_halfExtent[0], scale_halfExtent[1], scale_halfExtent[2] );
		Displaylists::Instance()->call(1);

	glPopMatrix();
}

BodypartRigidBox::~BodypartRigidBox()
{
}
